import request from "@/utils/request"

const url = '/oOrders'

// 生成订单
export function createOrderAPI({ addrId, orderDetailVos }) {
    return request({
        url: `${url}/generatedOrder`,
        method: 'POST',
        data: {
            addrId,
            orderDetailVos
        }
    })
}

//结算订单
export function pay4OrderAPI({ addrId, orderIdList, payMethod }) {
    return request({
        url: `${url}/payForOrder`,
        method: 'POST',
        data: {
            addrId,
            orderIdList,
            payMethod
        }
    })
}

// 获取用户订单（购买）
export function getOwnOrderAPI(status) {
    return request({
        url: `${url}/getMyOrder/${status}`
    })
}

// 获取用户（卖出）
export function getOwnSaleOrderAPI() {
    return request({
        url: `${url}/getSaleOrder`
    })
}

// 确定收货
export function confirmOrderAPI(id) {
    return request({
        url: `${url}/confirmReceipt`,
        params: {
            id
        }
    })
}

// 删除订单
export function delOrderAPI(id) {
    return request({
        url: `${url}/delete`,
        params: {
            id
        }
    })
}

// 根据订单号获取订单信息
export function getOrderDatailAPI(orderId) {
    return request({
        url: `${url}/getOrderByID`,
        params: {
            orderId
        }
    })
}

// 订单发货
export function shipMentsAPI(orderId) {
    return request({
        url: `${url}/shipments`,
        params: {
            orderId
        }
    })
}

// 获取订单的商品信息
export function getProductInfoAPI(id) {
    return request({
        url: `${url}/product`,
        params: {
            id
        }
    })
}